﻿using SqlSugar;

namespace Jst.Infrastructure.DbFirst
{
    public class TempDbFirstJob
    {
        private readonly ISqlSugarClient _db;

        public TempDbFirstJob(ISqlSugarClient db) => _db = db;

        public void RunOnce()
        {
            var slnDir = Directory.GetParent(AppContext.BaseDirectory)!
                                  .Parent!.Parent!.Parent!.FullName;

            var output = Path.Combine(slnDir, "Jst.Domain", "Entities");

            _db.DbFirst
               .IsCreateAttribute()
               .CreateClassFile(output, "Jst.Domain.Entities");
        }
    }
}
